import './index.scss'
import {useDispatch, useSelector} from "react-redux";
import {increment, decrement, incrementByAmount} from "@/features/counter/counterSlice.js";

export default function Counter() {
  const count = useSelector((state) => state.counter.count)
  const dispatch = useDispatch()

  return(
    <div>
      <div className='count'>数量：{count}</div>
      <div className='con'>
        <div className="btn" onClick={() => dispatch(increment())}>增加</div>
        <div className="btn" onClick={() => dispatch(decrement())}>减少</div>
        <div className="btn" onClick={() => dispatch(incrementByAmount(2))}>增加2</div>
      </div>
    </div>
  )
}
